const path = require('path');

function getMimeType(filePath) {
  switch (path.extname(filePath).substring(1)) {
    case 'gz':
      return 'application/gzip';
    case 'js':
    case 'mjs':
    case 'bundle':
      return 'application/javascript';
    case 'json':
    case 'map':
      return 'application/json';
    case 'cjs':
      return 'application/node';
    case 'pdf':
      return 'application/pdf';
    case 'mp4s':
    case 'm4p':
      return 'application/mp4';
    case 'zip':
      return 'application/zip';
    case 'm4a':
    case 'mp4a':
      return 'audio/mp4';
    case 'mpga':
    case 'mp2':
    case 'mp2a':
    case 'mp3':
    case 'm2a':
    case 'm3a':
      return 'audio/mpeg';
    case 'oga':
    case 'ogg':
    case 'spx':
    case 'opus':
      return 'audio/ogg';
    case 'sil':
      return 'audio/silk';
    case 'wav':
      return 'audio/wav';
    case 'weba':
      return 'audio/webm';
    case 'ttc':
      return 'font/collection';
    case 'otf':
      return 'font/otf';
    case 'ttf':
      return 'font/ttf';
    case 'woff':
      return 'font/woff';
    case 'woff2':
      return 'font/woff2';
    case 'gif':
      return 'image/gif';
    case 'heic':
      return 'image/heic';
    case 'heics':
      return 'image/heic-sequence';
    case 'heif':
      return 'image/heif';
    case 'heifs':
      return 'image/heif-sequence';
    case 'jp2':
    case 'jpg2':
      return 'image/jp2';
    case 'jpeg':
    case 'jpg':
    case 'jpe':
      return 'image/jpeg';
    case 'png':
      return 'image/png';
    case 'svg':
    case 'svgz':
      return 'image/svg+xml';
    case 'tif':
    case 'tiff':
      return 'image/tiff';
    case 'webp':
      return 'image/webp';
    case 'mp4':
    case 'mp4v':
    case 'mpg4':
      return 'video/mp4';
    case 'mpeg':
    case 'mpg':
    case 'mpe':
    case 'm1v':
    case 'm2v':
      return 'video/mpeg';
    case 'ogv':
      return 'video/ogg';
    case 'qt':
    case 'mov':
      return 'video/quicktime';
    case 'webm':
      return 'video/webm';
  }
}

module.exports = { getMimeType };
